home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2011 November
/
CHIP_2011_11.iso
/
Programy
/
Inne
/
Gry
/
Carnage_Contest
/
scripts
/
CC Original
/
weapons
/
Anvil.lua
< prev
next >
Wrap
Text File
|
2010-08-31
|
4KB
|
120 lines
--------------------------------------------------------------------------------
-- Weapon Anvil + Projectile Anvil
-- Original Carnage Contest Weapon
-- Script by DC, August 2009, www.UnrealSoftware.de
--------------------------------------------------------------------------------
-- Setup Tables
if cc==nil then cc={} end
cc.anvil={}
cc.anvil.anvil={}
-- Load & Prepare Ressources
cc.anvil.gfx_wpn=loadgfx("weapons/rc.bmp") -- Weapon Image
setmidhandle(cc.anvil.gfx_wpn)
cc.anvil.gfx_pro=loadgfx("weapons/anvil.bmp") -- Projectile Image
setmidhandle(cc.anvil.gfx_pro)
cc.anvil.sfx_hit=loadsfx("buildmetal.ogg")
--------------------------------------------------------------------------------
-- Weapon: anvil
--------------------------------------------------------------------------------
cc.anvil.id=addweapon("cc.anvil","Anvil",cc.anvil.gfx_pro,0,3) -- Add Weapon (0 uses, first in round 3)
function cc.anvil.draw() -- Draw
setblend(blend_alpha)
setalpha(1)
setcolor(255,255,255)
drawinhand(cc.anvil.gfx_wpn,7,0)
-- HUD Positioning
if weapon_shots==0 then
hudpositioning(pos_invisible)
end
end
function cc.anvil.attack(attack) -- Attack
if (weapon_shots<=0) and (weapon_position==1) then
-- No more weapon switching!
useweapon(0)
--playsound(cc.anvil.sfx_attack)
weapon_shots=weapon_shots+1
-- Attack
pid=createprojectile(cc.anvil.anvil.id)
projectiles[pid]={}
projectiles[pid].x=weapon_x
projectiles[pid].y=-500
projectiles[pid].sx=0
projectiles[pid].sy=3.0
-- End Turn
endturn()
end
end
--------------------------------------------------------------------------------
-- Projectile: anvil
--------------------------------------------------------------------------------
cc.anvil.anvil.id=addprojectile("cc.anvil.anvil") -- Add Projectile
function cc.anvil.anvil.draw(id) -- Draw
-- Setup draw mode
setblend(blend_alpha)
setalpha(1)
setcolor(255,255,255)
setscale(1,1)
setrotation(0)
-- Draw projectile
drawimage(cc.anvil.gfx_pro,projectiles[id].x,projectiles[id].y)
end
function cc.anvil.anvil.update(id) -- Update
-- Particle Tail
particle(p_smoke,projectiles[id].x,projectiles[id].y)
particlespeed(math.random(-2,2)*0.1,math.random(-2,2)*0.1)
particlefadealpha(0.05)
-- Gravity influence on speed
projectiles[id].sy=projectiles[id].sy+getgravity()
-- Move (in substep loop for optimal collision precision)
msubt=math.ceil(math.max(math.abs(projectiles[id].sx),math.abs(projectiles[id].sy))/2)
msubx=projectiles[id].sx/msubt
msuby=projectiles[id].sy/msubt
for i=1,msubt,1 do
projectiles[id].x=projectiles[id].x+msubx
projectiles[id].y=projectiles[id].y+msuby
-- Collision
if collision(cc.anvil.gfx_pro,projectiles[id].x,projectiles[id].y)==1 then
if playercollision()~=0 then
playerdamage(playercollision(),10000)
playsound(sfx_splatter2)
else
if objectcollision()~=0 then
objectdamage(objectcollision(),10000)
end
-- Destroy terrain
terrainexplosion(projectiles[id].x,projectiles[id].y,25,1)
playsound(cc.anvil.sfx_hit)
-- Particles
for j=1,30,1 do
particle(p_smoke,projectiles[id].x,projectiles[id].y)
particlespeed(math.random(-10,10)*0.1,math.random(-10,10)*0.1)
particlefadealpha(0.01)
end
-- Free projectile
freeprojectile(id)
break
end
end
-- Water
if (projectiles[id].y)>getwatery()+5 then
-- Effects
particle(p_waterhit,projectiles[id].x,projectiles[id].y)
playsound(sfx_hitwater1)
-- Free projectile
freeprojectile(id)
break
end
end
-- Scroll to projectile
scroll(projectiles[id].x,projectiles[id].y)
end